package test08.ts01;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * @Author czl
 * @Date 2024-04-15
 */
public class MainTest03 {
    public static void main(String[] args) {
        Integer [] arr = {1,2,7,4,3,6,5};

        //Stream<Integer> stream = Stream.of(arr);

        Integer reduce = Stream.of(arr).reduce(1,(t, u) -> t * u);
        Optional<Integer> reduce1 = Stream.of(arr).reduce((t, u) -> t < u ? t : u);
        Optional<Integer> reduce2 = Stream.of(arr).reduce((t, u) -> t > u ? t : u);

        System.out.println("求积：" + reduce);
        System.out.println("最小值：" + reduce1.get());
        System.out.println("最大值：" + reduce2.get());
    }
}
